import wechat from '../wechat-lib'
import configs from 'config'
export const getWechat = () => {
  const wechatClient = new wechat();
  return wechatClient;
}
export const signature = async (url)=>{
  const wechatClient = new wechat();
  const accessToken = await wechatClient.fetchAccessToken();
  const ticket = await wechatClient.fetchTicket(accessToken);
  const sign = wechatClient.sign(ticket,url)
  const signatureObj = {
    appId:configs.get('appID'),
    timestamp:sign.timestamp,
    nonceStr:sign.noncestr,
    signature:sign.signature
  }
  return signatureObj
}